package com.lixianhe.onlineexam.controller;


import com.lixianhe.onlineexam.pojo.JudgeQuestion;
import com.lixianhe.onlineexam.service.JudgeQuestionService;
import com.lixianhe.onlineexam.util.ApiResultHandler;
import com.lixianhe.onlineexam.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class JudgeQuestionController {
    @Autowired
    private JudgeQuestionService judgeQuestionService;

    @PostMapping("judgeQuestion")
    public R judgeQuestion(@RequestBody JudgeQuestion judgeQuestion) {
        int res = judgeQuestionService.addJudgeQuestion(judgeQuestion);
        if (res == 1) return ApiResultHandler.buildApiResult(200, "添加成功", res);
        return ApiResultHandler.buildApiResult(400, "添加失败", res);
    }

    @GetMapping("judgeQuestionId")
    public R judgeQuestionId() {
        JudgeQuestion judgeQuestion = judgeQuestionService.judgeQuestionId();
        return ApiResultHandler.buildApiResult(200, "查询判断题ID", judgeQuestion);
    }
}
